#include<bits/stdc++.h>
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define mid ((l+r)>>1)
#define File(xxx) freopen(xxx".in","r",stdin),freopen(xxx".out","w",stdout)
#define ls (x<<1)
#define rs ((x<<1)|1)
using namespace std;
namespace IO{
    char buff[1<<21],*p1=buff,*p2=buff;
    char getch(){
        return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;
    }
    template<typename T>
    void read(T &x){
        char ch=getch();int fl=1;x=0;
        while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getch();}
        while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getch();}
        x*=fl;
    }
    template<typename T,typename ...Args>
    void read(T &x,Args& ...args){
        read(x);read(args...);
    }
    char obuf[1<<21],*p3=obuf;
    void putch(char ch){
        if(p3-obuf<(1<<21))*p3++=ch;
        else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
    }
    void pc(const char *s){
    	while(*s)putch(*s),s++;
    }
    char ch[100];
    template<typename T>
    void write(T x){
        if(!x)return putch('0');
        if(x<0)putch('-'),x*=-1;
        int top=0;
        while(x)ch[++top]=x%10+48,x/=10;
        while(top)putch(ch[top]),top--;
    }
    template<typename T,typename ...Args>
    void write(T x,Args ...args){
        write(x),putch(' '),write(args...);
    }
    void flush(){fwrite(obuf,p3-obuf,1,stdout);p3=obuf;}
}
using namespace IO;
const int N=5e5+5;
struct SGT1{
	struct node{
		int minn,maxn,val,tag;
	}tree[N<<2];
	void update(int x){
		tree[x].minn=min(tree[ls].minn,tree[rs].minn);
		tree[x].maxn=max(tree[ls].maxn,tree[rs].maxn);
		tree[x].val=min(tree[ls].val,tree[rs].val);
	}
	void build(int x,int l,int r){
		if(l==r){
			tree[x].minn=tree[x].maxn=r;
			tree[x].val=1,tree[x].tag=0;
			return;
		}
		build(ls,l,mid),build(rs,mid+1,r);
		return update(x);
	}
	void add(int x,int l,int r,int tag){
		tree[x].minn=tree[x].maxn=tag;
		tree[x].val=tag-r+1;
		tree[x].tag=tag;
	}
	void push_down(int x,int l,int r){
		if(!tree[x].tag)return;
		add(ls,l,mid,tree[x].tag);
		add(rs,mid+1,r,tree[x].tag);
		tree[x].tag=0;
	}
	void change(int x,int l,int r,int v){
		if(tree[x].maxn<=v)return add(x,l,r,v);
		if(tree[x].minn>=v)return;
		push_down(x,l,r);
		change(ls,l,mid,v),change(rs,mid+1,r,v);
		return update(x);
	}
	void modify(int x,int l,int r,int L,int R,int v){
		if(L<=l&&r<=R)return change(x,l,r,v);
		push_down(x,l,r);
		if(R<=mid)modify(ls,l,mid,L,R,v);
		else if(L>mid)modify(rs,mid+1,r,L,R,v);
		else modify(ls,l,mid,L,R,v),modify(rs,mid+1,r,L,R,v);
		return update(x);
	}
	int query(int x,int l,int r,int L,int R){
		if(L<=l&&r<=R)return tree[x].val;
		push_down(x,l,r);
		if(R<=mid)return query(ls,l,mid,L,R);
		else if(L>mid)return query(rs,mid+1,r,L,R);
		else return min(query(ls,l,mid,L,R),query(rs,mid+1,r,L,R));
	}
}T1;
struct SGT2{
	int cnt[N];
	int tree[N<<2];
	void build(int x,int l,int r){
		tree[x]=N;
		if(l==r)return;
		build(ls,l,mid),build(rs,mid+1,r);
		return;
	}
	void modify(int x,int l,int r,int w,int v){
		if(l==r){
			cnt[w]+=v;
			if(!cnt[w])tree[x]=N;
			else tree[x]=w;
			return;
		}
		if(w<=mid)modify(ls,l,mid,w,v);
		else modify(rs,mid+1,r,w,v);
		tree[x]=min(tree[ls],tree[rs]);
		return;
	}
	int query(int x,int l,int r,int L,int R){
		if(L<=l&&r<=R)return tree[x];
		if(R<=mid)return query(ls,l,mid,L,R);
		else if(L>mid)return query(rs,mid+1,r,L,R);
		else return min(query(ls,l,mid,L,R),query(rs,mid+1,r,L,R));
	}
}T2;
int n,m,q;
int fa[N];
inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int last[N];
int ans[N];
vector<pair<int,int>>Q[N];
signed main(){
	File("destory");
	read(n,m,q);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<=m;i++){
		int x,y;
		read(x,y);
		x=find(x),
		y=find(y);
		fa[x]=y;
	}
	for(int i=1;i<=q;i++){
		int l,r;
		read(l,r);
		Q[r].push_back({l,i});
	}
	T1.build(1,1,n);
	T2.build(1,1,n);
	for(int i=1;i<=n;i++){
		{
			int c=find(i);
			T1.modify(1,1,n,last[c]+1,i,i);
			if(last[c])T2.modify(1,1,n,last[c],-1);
			T2.modify(1,1,n,i,1);
			last[c]=i;
		}
		for(auto p:Q[i]){
			int l=p.first,id=p.second;
			int r=T2.query(1,1,n,l,i);
			ans[id]=T1.query(1,1,n,l,r);
		}
	}
	for(int i=1;i<=q;i++)
		write(ans[i]),putch('\n');
	return flush(),0;
}
